use std::{net::IpAddr, sync::atomic::AtomicU64};
use local_ip_address::list_afinet_netifas;
use std::sync::atomic::Ordering;
use std::future::Future;

pub fn get_ip_addresses() -> Vec<String> {
    let mut ip_addresses = Vec::new();

    match list_afinet_netifas() {
        Ok(netifs) => {
            for (_, ip) in netifs {
                if let IpAddr::V4(ipv4) = ip {
                    if !ipv4.is_loopback() && !ipv4.is_link_local() {
                        ip_addresses.push(ipv4.to_string());
                    }
                }
            }
        },
        Err(e) => {
            eprintln!("Failed to get network interfaces: {}", e);
        }
    }
    ip_addresses
}
